<template>
  <div class="container bg-gray">
    <div class="form-items fz30">
      <div class="form-item flex border-b rel">
        <div class="txt333">
          行业：
        </div>
        <div class="flex-con txt333">
           {{professionIndustry[formData.professionIndustry]||'请选择企业性质'}}
          <select class="full-opacity" v-model="formData.professionIndustry">
            <option disabled>请选择企业性质</option>
            <option :value="key" v-for="(item,key) in professionIndustry" :key="key">{{item}}</option>
          </select>
        </div>
        <img src="../../assets/imgs/other/gt@2x.png" alt="" class="gt" />
      </div>
      <div class="form-item flex border-b">
        <div class="txt333">
          企业性质：
        </div>
        <div class="flex-con txt333">
         {{enterpriseProperty[formData.enterpriseProperty]||'请选择行业'}}
          <select class="full-opacity" v-model="formData.enterpriseProperty">
            <option disabled>请选择行业</option>
            <option :value="key" v-for="(item,key) in enterpriseProperty" :key="key">{{item}}</option>
          </select>
        </div>
        <img src="../../assets/imgs/other/gt@2x.png" alt="" class="gt" />
      </div>
      <div class="form-item flex border-b">
        <div class="txt333">
          企业规模：
        </div>
        <div class="flex-con txt333">
          {{enterpriseScale[formData.enterpriseScale]||'请选择企业规模'}}
          <select class="full-opacity" v-model="formData.enterpriseScale">
            <option disabled>请选择企业规模</option>
            <option :value="key" v-for="(item,key) in enterpriseScale" :key="key">{{item}}</option>
          </select>
        </div>
        <img src="../../assets/imgs/other/gt@2x.png" alt="" class="gt" />
      </div>

      <div class="form-item flex border-b">
        <div class="txt333">
          职业等级：
        </div>
        <div class="flex-con txt333">
          {{positionGrade[formData.positionGrade]||'请选择职业等级'}}
          <select class="full-opacity" v-model="formData.positionGrade">
            <option disabled>请选择职业等级</option>
            <option :value="key" v-for="(item,key) in positionGrade" :key="key">{{item}}</option>
          </select>
        </div>
      </div>

      <label class="form-item flex border-b">
        <div class="txt333">
          职业名称：
        </div>
        <div class="flex-con txt999">
          <input type="text" class="full-txt-input" v-model="formData.professionname" placeholder="请输入职业名称，如：财务经理">
        </div>
      </label>

    </div>
    <div class="btn-areas">
      <div class="btn-submit" @click="doSubmit">提交</div>
    </div>
  </div>
</template>
<script>
import {
  enterpriseProperty,
  professionIndustry,
  enterpriseScale,
  positionGrade
} from "../../config/constants";
export default {
  data() {
    return {
      formData: {},
      enterpriseProperty,
      professionIndustry,
      enterpriseScale,
      positionGrade
    };
  },
  created() {
    this.showLoading();
    this.$post("/api/user/profession/show")
      .then(data => {
        this.hideLoading();
        this.formData = data;
      })
      .catch(_ => {
        this.hideLoading();
      });
  },
  methods: {
    doSubmit() {
      if (
        this.$assert("isEmpty", this.formData.enterpriseProperty, "请选择行业")
      ) {
        return;
      }
      if (
        this.$assert(
          "isEmpty",
          this.formData.professionIndustry,
          "请选择企业性质"
        )
      ) {
        return;
      }
      if (
        this.$assert("isEmpty", this.formData.enterpriseScale, "请选择企业规模")
      ) {
        return;
      }
      if (
        this.$assert("isEmpty", this.formData.positionGrade, "请选择职业等级")
      ) {
        return;
      }
      if (
        this.$assert("isEmpty", this.formData.professionname, "请输入职业名称")
      ) {
        return;
      }
      this.showLoading();

      this.$post("/api/user/save_profession", this.formData)
        .then(_ => {
          this.$toast("提交成功");
          this.$router.go(-1);
          this.hideLoading();
        })
        .catch(_ => {
          this.hideLoading();
        });
    }
  }
};
</script>

<style lang="scss" scoped>
.btn-areas {
  padding-top: 0.7867rem;
  text-align: center;
  .btn-submit {
    display: inline-block;
    width: 8.4667rem;
    height: 1.0667rem;
    line-height: 1.0667rem;
    color: white;
    font-size: 0.4267rem;
    background-image: url("../../assets/imgs/other/btn.png");
    background-size: 100% 100%;
    background-position: left top;
  }
}

.question-icon {
  width: 0.6667rem;
  height: 0.6667rem;
}

.form-items {
  padding-top: 0.4rem;

  .form-item {
    padding: 0.4133rem 0.4667rem;
    background-color: #fff;
    .txt333 {
      width: 2.4267rem;
    }
    input {
      width: 100%;
      border: none;
      outline: none;
    }
  }
}

.down-icon {
  width: 0.28rem;
  height: 0.1467rem;
}

.unit {
  width: 1.48rem;
  height: 0.84rem;
  line-height: 0.84rem;
  font-size: 0.4rem;
  text-align: center;
  background-color: #e2e2e2;
  border-radius: 0.0933rem;
}
</style>
